<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>autocomplete plugin of jQuery</title>
<link href="../theme/pencil.autocomplete.css" rel="Stylesheet" />
</head>
<body>


<input type="text" />




<script src="../scripts/jquery-1.6.4.js"></script>
<script src="../scripts/jquery.pencil.autocomplete.js"></script>
<script src="../scripts/jquery.mockjax.js"></script>


<script>

$.mockjax({
	url: "/search/suggest",
	responseTime: 1,
	response: function(settings){
		var keyword = settings.data.q,
			timestamp = ($.now() + "").substr(-3, 3),
			result =  {
				"供应信息": ["Iphone4", "Iphone4s", "Iphone4外壳", "Iphone4数据线", "Iphone4充电器"],
				"新闻资讯": ["Iphone4性能测试","Iphone5最新信息曝光","Iphone4应用热门下载排行","Iphone4功能与设置详解"]
			};
		
		$.each(result, function(_, items){
			$.each(items, function(i, item){
				items[i] = item + timestamp;
			});
		});
		
		this.responseText = result['供应信息'];
	}
});


$("input").autocomplete({
	source: "/search/suggest"
});
</script>

</body>
</html>